var baseURL = "api/"
//var baseURL = "http://szxxlsw.com:8080/"

$(function() {

	document.body.style.setProperty('--themeColor', '#009b4c');
	document.body.style.setProperty('--themeJb', 'linear-gradient(#00c460, #009b4c)');

	$("#head").append(`<div class="row">
				<div class="w-100 d-flex justify-content-between" style="height: 100px;">
					<a href="http://szxxlsw.com" style="margin-left:20px;margin-top: 25px;">
						<img id="cLogo" src="" width="426px" height="48px" alt="深圳市消消乐有害生物防治有限公司" />
					</a>
					<div style="margin-right:20px;margin-top: 35px;">
						<img id="cTel" src="" alt="18038146110">
					</div>
				</div>
				<ul class="menv jb d-flex justify-content-between w-100">
					<li>
						<a class="xs_li_06 active" href="./index.html">网站首页</a>
					</li>
					<li>
						<a class="xs_li_06" href="./content.html?pId=1">关于我们</a>
					</li>
					<li>
						<a class="xs_li_06" href="./articleList.html?pId=2">新闻中心</a>
					</li>
					<li>
						<a class="xs_li_06" href="./projectList.html?pId=4">产品与服务</a>
					</li>
					<li>
						<a class="xs_li_06" href="./caseList.html?pId=5">客户案例</a>
					</li>
					<li>
						<a class="xs_li_06" href="./message.html">在线留言</a>
					</li>
					<li>
						<a class="xs_li_06" href="./content1.html?pId=6">联系我们</a>
					</li>
				</ul>
			</div>`)

	//	数据
	$.ajax({
		type: "POST",
		async: false,
		url: baseURL + "companyInfo/queryCompanyInfoById.do",
		data: {},
		dataType: "json",
		success: function(res) {
			console.log({
				公司信息: res
			})
			$("#cLogo").attr("src", res.data[0].logoImageUrl)
			$("#cImg").attr("src", res.data[0].companyImageUrl)
			$("#cName").text(res.data[0].companyInfo)
			$("#cTel").attr("src", res.data[0].companyPhone)
			$("#cCont").text(res.data[0].companySketch)
			$("#foot").html(res.data[0].companyWebInfo)
		}
	});

	//	客服
	$("body").append(`<div class="main-im">
		<div id="open_im" class="open-im">&nbsp;</div>  
		<div class="im_main" id="im_main">
			<div id="close_im" class="close-im"><a href="javascript:void(0);" title="点击关闭">&nbsp;</a></div>
			<a href="http://wpa.qq.com/msgrd?v=3&uin=190989857&site=qq&menu=yes" target="_blank" class="im-qq qq-a" title="江先生">
				<div class="qq-container"></div>
				<div class="qq-hover-c"><img class="img-qq" src="img/qq.png"></div>
				<span> QQ在线咨询</span>
			</a>
			<div class="im-tel">
				<div>售前咨询热线</div>
				<div class="tel-num">18038146110</div>
				<div>售后咨询热线</div>
				<div class="tel-num">18038146110</div>
			</div>
			<div class="im-footer" style="position:relative">
				<div class="weixing-container">
					<div class="weixing-show">
						<div class="weixing-txt">微信扫一扫<br>关注消消乐</div>
						<img class="weixing-ma" src="img/weixing-ma.jpg">
						<div class="weixing-sanjiao"></div>
						<div class="weixing-sanjiao-big"></div>
					</div>
				</div>
				<div class="go-top"><a href="javascript:;" title="返回顶部"></a> </div>
				<div style="clear:both"></div>
			</div>
		</div>
	</div>`)

	$('#close_im').bind('click', function() {
		$('#main-im').css("height", "0");
		$('#im_main').hide();
		$('#open_im').show();
	});
	$('#open_im').bind('click', function(e) {
		$('#main-im').css("height", "272");
		$('#im_main').show();
		$(this).hide();
	});
	$('.go-top').bind('click', function() {
		$(window).scrollTop(0);
	});
	$(".weixing-container").bind('mouseenter', function() {
		$('.weixing-show').show();
	})
	$(".weixing-container").bind('mouseleave', function() {
		$('.weixing-show').hide();
	});



function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return decodeURI(r[2]);
	return null;
}

getNav2(8)

function getNav2(pId) {
	$.ajax({
		type: "POST",
		async: false,
		url: baseURL + "lable/queryWebLableList.do",
		data: {
			pId: pId
		},
		dataType: "json",
		success: function(res) {
			qureryCard(res.data[0].id,0)
			qureryCard(res.data[1].id,1)
		}
	});

	//查询文章（全部）
	function qureryCard(id,num) {
		$.ajax({
			type: "POST",
			async: false,
			url: baseURL + "article/queryList.do",
			data: {
				lableId: id,
				pageNo: "1",
				pageSize: "1",
				isShow: "1"
			},
			dataType: "json",
			success: function(res) {
				if(num==0){
					$("#contact").append(res.data.list[0].details)
				}
				if(num==1){
					$("#contact2").append(res.data.list[0].details)
				}
			}
		});
	}
}



})


function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return decodeURI(r[2]);
	return null;
}